package com.vonchange.utils.crud.dao.impl;

import java.util.List;




import com.bstek.dorado.data.provider.Page;
import com.vonchange.headb.core.bean.SqlParmeter;
import com.vonchange.headb.core.map.HeaMap;
import com.vonchange.headb.spring.dao.impl.HeaDaoImpl;
import com.vonchange.utils.crud.dao.IBaseDao;


public abstract class BaseDaoImpl<T> extends   HeaDaoImpl<T>  implements IBaseDao<T>{
  	@Override
	public Page<T> findPageDR(Page<T> page, HeaMap parameter){
		SqlParmeter sqlParmeter = generateQuerySql(parameter);
		String sql = sqlParmeter.getSql();
		Object[] params = sqlParmeter.getParameters();
		long totalCount = countMySqlResult(sql, params);
		page.setEntityCount((int) totalCount);
		sql = dialect.getPageSql(sql, page.getFirstEntityIndex(), page.getLastEntityIndex());
		List<T> entities = queryList(sql, params, sqlParmeter.getAliasMap());
		page.setEntities(entities);
		return page;
   }
}
